package com.zc.servicedemo;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;

public class MainActivity extends Activity {
	
	public static final String TAG = MainActivity.class.getSimpleName();
	
	Button btn1;
	Button btn2;
	Button btn3;
	Button btn4;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initAction();

    }
    
    private void initView(){
    	btn1 = (Button) findViewById(R.id.btn1);
    	btn2 = (Button) findViewById(R.id.btn2);
    	btn3 = (Button) findViewById(R.id.btn3);
    	btn4 = (Button) findViewById(R.id.btn4);
    }
    
    private void initAction(){
    	btn1.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent("com.zcl.start");
				startService(intent);
			}
		});
    	btn2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent("com.zcl.end");
				startService(intent);
			}
		});
    	btn3.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				List<String> depart = new ArrayList<String>();
				depart.add("com.tencent.qqpinyin");
				depart.add("com.dragon.android.pandaspace");
				PackageInfo pi = SystemUtils.getMaxApp(MainActivity.this, depart);
				Log.i(TAG, pi.packageName);
			}
		});
    	btn4.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				MonkeyUtils.monkeyApp("com.zcl.funnygame", 500);
			}
		});
    }
}
